﻿using System.Windows.Controls;
using VupSlashLauncher.Common;
using VupSlashLauncher.Model;

namespace VupSlashLauncher.View
{
    /// <summary>
    /// SettingViewGameSettingView.xaml 的交互逻辑
    /// </summary>
    public partial class SettingViewGameSettingView : UserControl
    {
        public SettingViewGameSettingView()
        {
            InitializeComponent();
        }

        private void GameHostIP_Changed(object sender, TextChangedEventArgs e)
        {
            string temp = (sender as TextBox).Text;
            if (!string.IsNullOrEmpty(temp))
            {
                GlobalValues.GameHostIP = temp;
                IFunc.WriteGameConfigFile("HostAddress", GlobalValues.GameHostIP);
            }
        }

        private void NameInGame_Changed(object sender, TextChangedEventArgs e)
        {
            string temp = (sender as TextBox).Text;
            if (!string.IsNullOrEmpty(temp))
            {
                GlobalValues.NameInGame = temp;
                IFunc.WriteGameConfigFile("UserName", IFunc.String2Unicode(GlobalValues.NameInGame));
            }
        }

        private void GameWindowSize_Changed(object sender, System.Windows.RoutedEventArgs e)
        {
            IFunc.WriteGameConfigFile("WindowSize", "@Size(" + GameWindowWidth.Text + " " + GameWindowHeight.Text + ")");
        }
    }
}
